<template>
  <div class="pagination red-pagination">
    <el-pagination
      background
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page.sync="curPage"
      :page-sizes="pageSizes"
      :page-size.sync="pageSize"
      :layout="layout"
      :total="total"
    >
    </el-pagination>
  </div>
</template>

<script>
export default {
  name: 'Pagination',
  methods: {
    handleSizeChange(val = this.limit) {
      this.$emit('change')
    },
    handleCurrentChange(val = this.page) {
      this.$emit('change')
    },
  },
  computed: {
    curPage: {
      get() {
        return this.page
      },
      set(val) {
        this.$emit('update:page', val)
      },
    },
    pageSize: {
      get() {
        return this.limit
      },
      set(val) {
        this.$emit('update:limit', val)
      },
    },
  },
  props: {
    total: {
      require: true,
      type: Number,
    },
    page: {
      require: true,
      type: Number,
      default: 1,
    },
    limit: {
      require: true,
      type: Number,
      default: 10,
    },
    pageSizes: {
      type: Array,
      default() {
        return [5, 8, 10, 12, 20, 50]
      },
    },
    layout: {
      type: String,
      default: 'total, prev, pager, next, jumper,sizes',
    },
  },
}
</script>
<style scoped>
.red-pagination
  >>> .el-pagination.is-background
  .el-pager
  li:not(.disabled):hover {
  color: var(--colorA1);
}
.red-pagination
  >>> .el-pagination.is-background
  .el-pager
  li:not(.disabled).active {
  background-color: var(--colorA1);
  color: #fff;
}
</style>